package com.txf.simple.ui.window;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.txf.simple.R;


/**
 * @author txf
 * @Title
 * @package com.wisdomag.ui.window
 * @date 2016/11/29 0029
 */

public class PermissionsDialog extends Dialog implements View.OnClickListener {
    private TextView btn;

    public PermissionsDialog(Context context) {
        super(context);
    }

    public PermissionsDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    protected PermissionsDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_permissions_layout);
        //点击外部不消失
        setCancelable(false);
        //返回键屏蔽
        setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    return true;
                }
                return false;
            }
        });
        initViews();
    }

    private void initViews() {
        btn = (TextView) findViewById(R.id.dialog_permissions_btn);
        btn.setOnClickListener(this);
    }
    private OnNextClickListener l;
    public interface OnNextClickListener {
        void onClick();
    }
    public void setOnNextClickListener(OnNextClickListener l) {
        this.l = l;
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.dialog_permissions_btn:
                if (l != null)
                    l.onClick();
                break;
        }
    }
    @Override
    public void show() {
        super.show();
    }
}
